﻿using System.Configuration;
using System;

namespace TestWeb.Helpers
{
    /// <summary>
    /// Class contains configurations of website
    /// </summary>
    public class WebConfiguration
    {
        /// <summary>
        /// The instance of web configuration
        /// </summary>
        public static WebConfiguration instance;

        /// <summary>
        /// This clock for synchronization
        /// </summary>
        private static object syncLock = new object();

        /// <summary>
        /// The singleton for creating web configuration
        /// </summary>
        public static WebConfiguration Instance
        {
            get
            {
                lock (syncLock)
                {
                    if (instance == null)
                        instance = new WebConfiguration();
                    return instance;
                }
            }
        }

        public int NumTinTucPerPage
        {
            get
            {
                return Int32.Parse(ConfigurationManager.AppSettings["NumTinTucPerPage"]);
            }
        }

        public int NumNguoiDungPerPage
        {
            get
            {
                return Int32.Parse(ConfigurationManager.AppSettings["NumNguoiDungPerPage"]);
            }
        }

        public int NumLoaiTinTucPerPage
        {
            get
            {
                return Int32.Parse(ConfigurationManager.AppSettings["NumLoaiTinTucPerPage"]);
            }
        }

        public string MailServer
        {
            get
            {
                return string.Empty;
            }
        }

        public int NumCharsOfShortDescription
        {
            get
            {
                return Int32.Parse(ConfigurationManager.AppSettings["NumCharsOfShortDescription"]);
            }
        }

        public Guid AccTest
        {
            get
            {
                return new Guid("82b02bfe-877a-43d4-a8f9-3e4974e31ac6");
            }
        }

        /// <summary>
        /// The time delay for an alert message
        /// </summary>
        public int AlertTime
        {
            get
            {
                return 2000;
            }
        }

        /// <summary>
        /// The time delay for an info message
        /// </summary>
        public int InfoTime
        {
            get
            {
                return 3000;
            }
        }
    }
}